import Vue from 'vue'
import Vuex from 'vuex'
import { cloneDeep } from 'lodash'
import user from './modules/user'
import app from './modules/app'
import requestbtn from './modules/requestbtn'
import bot from './modules/bot'
import design from './modules/design'
import dashboard from './modules/dashboard'
import drillThrough from './modules/drillThrough'
import system from './modules/system'
import permission from './modules/permission'
import getters from './getters'
import nextTicket from '@/store/modules/nextTicket'
import attendance from './modules/attendance'
import publicReport from './modules/publicReport'
import sqlAgent from './modules/sqlAgent'
import report from './modules/report'
import ai from './modules/ai'
Vue.use(Vuex)

export default new Vuex.Store({
  namespaced: true,
  state: {
    navbarLayoutType: 'colorful',
    sidebarLayoutSkin: 'light',
    sidebarFold: false,
    sidebarMenuList: [],
    sidebarMenuActiveName: '',
    contentIsNeedRefresh: false,
    REFRESHCACHE: false,
    contentTabs: [
      {
        ...window.SITE_CONFIG['contentTabDefault'],
        'name': 'home',
        'title': 'home',
        'menuId': 'home'
      }
    ],
    contentTabsActiveName: 'home',
    GetStarted: {
      dialogStatus: false,
      steps: 0,
      configList: []
    },
    rowData: null,
    isWidget: false,
    defaultRoleList: [],
    refreshCardList: null,
    refreshQuickFilter: null,
    siteWebConfig:{
      'icon':'logo_left.png',
      'login_bgimg':'jjbgc.png',//'login_background.png', 
      'login_img':'denglutu.png',
      'login_mask':'mengceng.png',
      'origin':'',
      'title':'一体化系统平台',
      'homePage':'home',
      'footer_1':'',
      'footer_2':'',
      'loginButtonColor':"#2F66F7"
    }
  },
  modules: {
    user,
    app,
    dashboard,
    drillThrough,
    design,
    system,
    permission,
    bot,
    requestbtn,
    nextTicket,
    attendance,
    sqlAgent,
    report,
    publicReport,
    ai
  },
  mutations: {
    resetStore (state) {
      Object.keys(state).forEach((key) => {
        state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
      })
    },
    SET_REFRESH_CARD_LIST: (state, value) => {
      state.refreshCardList = value
    },
    SET_REFRESH_QUICK_FILTER: (state, value) => {
      state.refreshQuickFilter = value
    },
    SET_SITE_WEB_CONFIG:(state,siteWebConfig) => {
      state.siteWebConfig = siteWebConfig
    }
  },
  actions: {
    changeCardList ({ commit }, value) {
      commit('SET_REFRESH_CARD_LIST', value)
    },
    changeQuickFilter ({ commit }, value) {
      commit('SET_REFRESH_QUICK_FILTER', value)
    }
  },
  getters
})
